package com.dapeis.core.utils.json;

import java.lang.reflect.Type;
import com.ag.utils.json.AGsonBuilder;
import com.dapeis.domain.ext.OrderExt;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonSerializationContext;
import com.google.gson.JsonSerializer;

/**
 * 
 * Title:OrderExtGsonAdapter.java OrderExtGsonAdapter Description:
 * 
 * @author yuanyong
 * @date 2017年5月9日 上午11:13:58 Email: hzyuanyong@126.com
 *
 */
public class OrderExtGsonAdapter implements JsonSerializer<OrderExt> {

    @Override
    public JsonElement serialize(OrderExt src, Type typeOfSrc,
	    JsonSerializationContext context) {
	JsonObject json = new JsonObject();
	/*
	 * if (null != src.getCollocation()) { json.add("collocation",
	 * AGsonBuilder.create().toJsonTree(src.getCollocation())); } else {
	 * json.add("collocation", AGsonBuilder.create().toJsonTree(new
	 * Object())); }
	 */
	json.add("user", AGsonBuilder.create().toJsonTree(src.getUserExt()));
	json.add("requirement",
		AGsonBuilder.create().toJsonTree(src.getRequirement()));
	json.add("comment", AGsonBuilder.create().toJsonTree(src.getComment()));
	return json;
    }

}
